/*
 * GoGame.cpp
 *
 *  Created on: May 30, 2011
 *      Author: hongyang
 */

#include "GoGame.h"
#include "Move.h"
#include <iostream>
using namespace std;

GoGame::GoGame()
: board(),
  regionBoard(board),
  moveGen(regionBoard)
{
}

GoGame::GoGame(GoGame& g)
: board(g.board),
  regionBoard(g.regionBoard),
  moveGen(g.moveGen)
{
}

GoGame::~GoGame() {
}

void GoGame::addMove(Move move) {
	board.play(move);
	regionBoard.onExecMove(move);
//	regionBoard.genRegions();
}

void GoGame::play(SgPoint p) {
	if(!board.isLegal(p, board.toPlay()))
		SgDebug() << "---------------illegal\n";
	Move m = Move(board.toPlay(), p);
	addMove(m);
}

Move GoGame::nextMove() {
	return moveGen.nextMove();
}

void GoGame::init() {
	board.init();
	regionBoard.clear();
}
